import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/jwt/login',
    method: 'post',
    data
  })
}

export function fetchList(query) {
  return request({
    url: '/user/page',
    method: 'get',
    params: query
  })
}

export function switchRole(roleId) {
  return request({
    url: '/jwt/switchRole',
    method: 'post',
    data: roleId 
  })
}
export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/jwt/loginOut',
    method: 'post'
  })
}

export function create(data){
  return request({
    url: '/user',
    method: 'post',
    data
  })
}

export function update(data){
  return request({
    url: '/user',
    method: 'put',
    data
  })
}

export function del(data){
  return request({
    url: '/user/'+data,
    method: 'delete'
  })
}

// 根据id或者对象
export function selectOne(id){
  return request({
    url: '/user/'+id,
    method: 'get'
  })

}
